import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;


public class FileObject {
	boolean debug = true;
	private File file = null;
	private long fileSize;
	public int nchunks;
	public String filename = null; //For FOUND files
	
//	public byte[][] chunks;
	
	public FileObject(File file, long fileSize){
		this.file = file;
		this.filename = file.getName();
		this.fileSize = fileSize;
		this.nchunks = (int) Math.round((this.fileSize - 1)/1024 + 0.5);
	}
	
	public FileObject(String filename, long fileSize){
		this.filename = filename;
		this.fileSize = fileSize;
		this.nchunks = (int) Math.round((this.fileSize - 1)/1024 + 0.5);
	}
	
	public void setFile(File file){
		this.file = file;
	}
	
	public File getFile(){
		return file;
	}
	
	public long getFileSize(){
		return fileSize;
	}

	public byte[] createChunk(long offset) throws IOException {
		byte dataChunk[] = new byte[1024];
		long realOffset = offset * 1024;
		// TODO Auto-generated method stub
		RandomAccessFile raf = new RandomAccessFile(file, "r");
		raf.seek(realOffset);
		raf.read(dataChunk);
		raf.close();

		//if(debug) System.out.println("Bytes read: " + read_bytes);
		return dataChunk;
	}
	
}
